Show drillthrough in "Child" reportviewer (jQuery)
Hi all, I am new here so forgive me if this is an unusual question.
I'd like to give my users the option to show drill through reports in a JQuery dialog window so they could "float" above the parent report in the same browser window. I don't build the reports, so I can't change to "Action" to go to a url, it's set to go
to another report (not that that would help as the url would be the same). I just want to hijack the process and pop up a JQuery dialog showing the drillthrough, while the parent stays in the main report.
Maybe in the drillthrough event handler I could "grab" the parameters being sent and pass them programmatically to the other report and then show the jquery dialog and cancel the drillthrough event on the original report?
I'm entirely comfortable with the JQuery aspects of handling the dialog window, it's just the issue of targeting the drillthrough to another reportviewer in the same aspx page that I'd like help with.
Thanks for your thoughts, Bob Graham.
October 14th, 2011 5:33pm
Actually, that was pretty easy, posting here for advantage of future browsers, but I do need help with a glitch...
Shown below is the code and a (sanitized) screen grab. One problem,
DrillDown isn't working in the dialog window. :-(
All the other nav controls work fine.
What am I doing wrong?
protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)
{
ReportParameterInfoCollection rpic = e.Report.GetParameters();
List<ReportParameter> paramList = new List<ReportParameter>();
foreach (ReportParameterInfo inf in rpic)
paramList.Add(new ReportParameter(inf.Name, inf.Values[0]));
string rPath = e.ReportPath;
reportView2.ServerReport.ReportServerUrl = new Uri("http://ServerName/reportserver");
reportView2.ServerReport.ReportPath = rPath;
reportView2.ServerReport.SetParameters(paramList);
reportView2.ServerReport.Refresh();
e.Cancel = true;
string script = @"$('#jqueryRpt').dialog({
title: 'Drill Through Report',
resizable: true,
modal: false,
show: 'blind',
hide: 'fade',
width: 550,
height: 700,
buttons: {
'Close': function() {
$(this).dialog('close');
}
}
});";
ScriptManager.RegisterStartupScript(this, this.GetType(), "open", script, true);
}
Free Windows Admin Tool Kit Click here and download it now
October 14th, 2011 7:10pm
Hi BobGraham789,
Thanks for your post and JQuery applying in SSRS.
According to your description, the DrillDown function doesn’t work in the JQuery dialog window. Please try
to show the report in the main .aspx page to do verification, if it works fine, we can conclude the problem should be caused by the JQuery add-in you used. As a result, I would suggest you to go to the relevant JQuery forum to seek some help.
Thanks,
Bill Lu
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
October 17th, 2011 1:27am
Hi Bill,
Thanks for your reply. If I comment out the code to show the drillthrough in the JQuery dialog, things work just fine, clicking any "+" sign expands the child rows as expected.
If I hijack the drillthrough and show it in a jquery window as above, the page navigation and all works fine, but clciking a "+" sign only causes a slight visual hiccup, both in the jquery window and the parent reportviewer toolbar.
The code attached to the event in the JQuery version is:
<a style="cursor: pointer;" tabIndex="6"
onkeypress="
if(event.keyCode == 13 || event.which == 13){
var rp=$get('reportView2_ctl09_ReportControl');
if(rp&&rp.control)rp.control.InvokeReportAction('Toggle','72iT0R0x5');
}return false;
"
onclick="
var rp=$get('reportView2_ctl09_ReportControl');
if(rp&&rp.control)rp.control.InvokeReportAction('Toggle','72iT0R0x5');
return false;
">
<img onerror="this.errored=true;" border="0" alt="+" src="/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=10.0.40219.1&Name=Microsoft.ReportingServices.Rendering.HtmlRenderer.RendererResources.TogglePlus.gif">
</a>
(line returns added by me)
The var it's referencing is valid, and points to the same object in the report as it does when displayed in the conventional manner, that is, in the parent report viewer. The reference to reportView2 is correct, that is the name of the "child" report viewer
in the jquery dialog. Just seems like the action is blocked and also bubbling up to the parent viewer, hence the visual hiccup in the parent toolbar controls.
I'm looking at changing this to use ReportExecution2005.asmx and binding it to a GridView in the JQuery dialog, and handling the automation myself. Do you know a good resource on that? I have safaribooksonline subscription but haven't yet found a well-rounded
walkthrough of manually handling the execution to a form that can be bound to a gridview.
Thanks, Bob Graham
Free Windows Admin Tool Kit Click here and download it now
October 17th, 2011 1:33pm
Hi BobGranham789,
Thanks for your feedback.
Based on the information you provided, we can we can conclude the problem should be caused by the JQuery add-in
you used, this is SQL Server Reporting Services forum, there are rarely few people are practiced to JQuery, so I would suggest to you to post it on the relevant
JQuery forum, there are more people who are proficient and experienced to JQuery in there, they would give a quick response to your issue.
Appreciate your understanding.
Thanks,
Bill Lu
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
October 18th, 2011 7:03am
Thanks again Bill.
I have posted a question there but got even less response than here. Lost in no man's land!
I think I will use reportexecution service to produce the report as html without a ReportViewer control and then use jquery to ajax the dropdown rows I need client-side.
Time to dig in and get busy with trial and error! Do you know a good resource on ReportExecution2005.asmx? Seems like that's the latest version. That is what I need to use to output the report as HTML isn't it? Or just the Render method in ReportServices2010.asmx
with RenderFormat of HTML or the like?
Thanks, Bob
Free Windows Admin Tool Kit Click here and download it now
October 18th, 2011 8:39pm
Hi BobGraham789,
You can refer to the link below to obtain detailed information about ReportExecution2005.asmx web service:
http://support.microsoft.com/kb/875447
http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx
Thanks,
Bill Lu
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
October 18th, 2011 9:20pm
Working perfectly now. The code shown earlier just needed one extra bit so that the jquery dialog would be considered by the browser to be part of the
same form. (Changes bolded):
protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)
{
ReportParameterInfoCollection rpic = e.Report.GetParameters();
List<ReportParameter> paramList = new List<ReportParameter>();
foreach (ReportParameterInfo inf in rpic)
paramList.Add(new ReportParameter(inf.Name, inf.Values[0]));
string rPath = e.ReportPath;
reportView2.ServerReport.ReportServerUrl = new Uri("http://ServerName/reportserver");
reportView2.ServerReport.ReportPath = rPath;
reportView2.ServerReport.SetParameters(paramList);
reportView2.ServerReport.Refresh();
e.Cancel = true;
string script = @"$('#jqueryRpt').dialog({
title: 'Drill Through Report',
resizable: true,
modal: false,
show: 'blind',
hide: 'fade',
width: 550,
height: 700,
buttons: {
'Close': function() {
$(this).dialog('close');
}
}
}).parent().appendTo($('#form1'));";
ScriptManager.RegisterStartupScript(this, this.GetType(), "open", script, true);
}
This is really a huge improvement on the default behavior of "losing" the parent report when viewing a drill-through. You can even click on other drill-through links in the parent report and the dialog will update.
Bob Graham
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 1:28pm
Hi Bob,
I have a similar situation I need to solve and I tried out your solution above. What I noticed is that the report is fired off twice (2 posts are sent of the the reportserver). It happens when the action is clicked, the first post returns and
calls the ReportViewer1_Drillthrough handler. Then stepping through that function there is another post when reportView2.ServerReport.Refresh(); is called.
Is this happening to you as well? Do you know if there is a workaround so it is only sent off once?
May 23rd, 2012 5:16pm